package org.mule.robo;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class TableTestCase
{

    @Test
    public void simpleMoveAontoB()
    {
        Table table = new Table(8);
        List<Command> commands = new ArrayList<Command>();
        commands.add(new MoveOntoCommand(7, 1));
        table.run(commands);

        assertEquals(table.position(7), 1);
        assertEquals(table.stack(7).size(), 0);
        assertEquals(table.stack(1).size(), 2);
        assertEquals(table.stack(1).peek(), new Integer(7));
        System.out.println(table.toString());
    }
/*
    @Test
    public void sampleOne()
    {
        Table table = new Table(8);
        table.moveAontoB(7, 1);
        table.moveAontoB(5, 1);
        table.moveAontoB(1, 6);
        table.moveAontoB(4, 3);
        table.moveAontoB(1, 4);
        table.moveAontoB(3, 1);
        table.moveAontoB(5, 2);
        table.moveAontoB(4, 5);
        assertEquals(table.stacks[0].stack.size(), 1);
        assertEquals(table.stacks[1].stack.size(), 1);
        assertEquals(table.stacks[2].stack.size(), 3);
        assertEquals(table.stacks[3].stack.size(), 1);
        assertEquals(table.stacks[4].stack.size(), 0);
        assertEquals(table.stacks[5].stack.size(), 0);
        assertEquals(table.stacks[6].stack.size(), 1);
        assertEquals(table.stacks[7].stack.size(), 1);
        System.out.println(table.toString());
    }

    @Test
    public void simpleMoveAoverB()
    {
        Table table = new Table(8);
        table.moveAoverB(7, 1);
        assertEquals(table.stacks[7].position, 1);
        assertEquals(table.stacks[7].stack.size(), 0);
        assertEquals(table.stacks[1].stack.size(), 2);
        assertEquals(table.stacks[1].stack.peek(), new Integer(7));
        System.out.println(table.toString());
    }

    @Test
    public void complexMoveAoverB()
    {
        Table table = new Table(8);
        table.moveAoverB(7, 1);
        table.moveAoverB(5, 1);
        assertEquals(table.stacks[7].position, 1);
        assertEquals(table.stacks[5].position, 1);
        assertEquals(table.stacks[1].position, 1);
        assertEquals(table.stacks[7].stack.size(), 0);
        assertEquals(table.stacks[5].stack.size(), 0);
        assertEquals(table.stacks[1].stack.size(), 3);
        assertEquals(table.stacks[1].stack.peek(), new Integer(5));
        assertEquals(table.stacks[1].stack.peekLast(), new Integer(1));
        System.out.println(table.toString());
    }

    @Test
    public void sampleTwo()
    {
        Table table = new Table(6);
        table.moveAontoB(4, 1);
        table.moveAontoB(3, 2);
        table.moveAoverB(2, 1);
        table.moveAontoB(4, 2);
        table.moveAoverB(5, 0);
        table.moveAoverB(4, 0);
        assertEquals(table.stacks[0].stack.size(), 3);
        assertEquals(table.stacks[1].stack.size(), 1);
        assertEquals(table.stacks[2].stack.size(), 1);
        assertEquals(table.stacks[3].stack.size(), 1);
        assertEquals(table.stacks[4].stack.size(), 0);
        assertEquals(table.stacks[5].stack.size(), 0);
        System.out.println(table.toString());
    }

    @Test
    public void sampleThree()
    {
        Table table = new Table(10);
        table.moveAontoB(9, 1);
        table.moveAoverB(8, 1);
        table.moveAoverB(7, 1);
        table.moveAoverB(6, 1);
        table.pileAontoB(8, 6);
        table.pileAontoB(8, 5);
        table.moveAoverB(2, 1);
        table.moveAoverB(4, 9);
        table.pileAontoB(8, 9);
        assertEquals(table.stacks[0].stack.size(), 1);
        //assertEquals(table.stacks[1].stack.size(), 2);
        assertEquals(table.stacks[1].stack.size(), 5);
        assertEquals(table.stacks[2].stack.size(), 1);
        assertEquals(table.stacks[3].stack.size(), 1);
        assertEquals(table.stacks[4].stack.size(), 1);
        assertEquals(table.stacks[5].stack.size(), 1);
        assertEquals(table.stacks[6].stack.size(), 0);
        assertEquals(table.stacks[7].stack.size(), 0);
        assertEquals(table.stacks[8].stack.size(), 0);
        //assertEquals(table.stacks[9].stack.size(), 4);
        assertEquals(table.stacks[9].stack.size(), 0);
        System.out.println(table.toString());
    }

    @Test
    public void sampleFour()
    {
        Table table = new Table(10);
        table.moveAontoB(9,1);
        table.moveAoverB(8, 1);
        table.moveAoverB(7, 1);
        table.moveAoverB(6, 1);
        table.pileAoverB(8, 6);
        table.pileAoverB(8, 5);
        table.moveAoverB(2, 1);
        table.moveAoverB(4, 9);
        assertEquals(table.stacks[0].stack.size(), 1);
        assertEquals(table.stacks[1].stack.size(), 4);
        assertEquals(table.stacks[2].stack.size(), 0);
        assertEquals(table.stacks[3].stack.size(), 1);
        assertEquals(table.stacks[4].stack.size(), 0);
        assertEquals(table.stacks[5].stack.size(), 4);
        assertEquals(table.stacks[6].stack.size(), 0);
        assertEquals(table.stacks[7].stack.size(), 0);
        assertEquals(table.stacks[8].stack.size(), 0);
        assertEquals(table.stacks[9].stack.size(), 0);
        System.out.println(table.toString());
    }
    */
}

